﻿using System;
using System.Text;
using YAFTS.Contracts;
using YAFTS.Core;
using YAFTS.Utils;

namespace YAFTS.ConsoleClient
{
	class Program
	{
		static void Main(string[] args)
		{
			using (var index = DefaultSearchEngine.Instance)
			{
				index.Configuration.DefaultEncoding = Encoding.GetEncoding(1251);
				index.Configuration.Filter = "*.txt";
				index.ProccessError += (sender, exceptionArgs) => Console.WriteLine("{0}. {1}", exceptionArgs.FileName, exceptionArgs.Exception);
				index.AddObservedDirectory(@"c:\Folder1\");
				while (true)
				{
					Console.WriteLine("enter query");

					var query = Console.ReadLine() ?? string.Empty;
					if(query == "exit()")
					{
						return;
					}

					index.ExecuteQuery(SearchOptions.AllWords, query.Split(' ')).ForEach(Console.WriteLine);
				}
			}
		}
	}
}
